<?php

namespace app\admin\controller;

use app\constant\EsConst;
use app\helper\EsHelper;
use think\Controller;

class Test extends Controller
{
    public function index()
    {
        $a = 1/0;
//        $esHelper = new EsHelper();
//        //创建索引
////        $esHelper->createIndex();
////        //添加数据
//        $esHelper->indexSingleDoc(EsConst::INDEX_TYPE,EsConst::TYPE_GOODS,1,['title'=>'9.9元抢原价99元烤牛肉套餐','goods_id'=>3]);
//        $search = [
//            'query' => [
//                'match' => [
//                    'title' => '烤肉'
//                ]
//            ]
//        ];
//        $result = $esHelper->search(EsConst::INDEX_TYPE,EsConst::TYPE_GOODS,$search);
//        echo json_encode($result);
//        try {
//            echo ("<info>进入判断：</info>");
//            $orderData = AdminOrder::get(['id' => '456f4ds56f4sd64f56sd', 'status' => OrderStatus::STATUS_UNPAY])->getData();
//            echo ("<info>数据查询：</info>");
//            if($orderData){
//                return true;
//            }else{
//                return false;
//            }
//        } catch (Exception $e) {
//            print("<info>出现异常：</info>");
//            return false;
//        }
//        $model = AdminOrder::get(['id' => 1, 'pay_status' => OrderConst::PAY_STATUS_UN_PAY_ONLINE]);
//        echo  json_encode($model->getData());
//        echo $_SERVER['HTTP_HOST'];
//        TokenHelper::updateToken(951);
//        Log::write("订单回调" .json_encode($this->request->post()), 'error');
//        echo $this->request->domain();
//        $isPushed=OrderHelper::pubCloseOrderQueue('BB14372103674365',10);
//        echo '发布' . $isPushed;
//        try {
//            Db::startTrans();
//            $done = VipHelper::addVipTime('951',2);
//            1/0;
//            Db::commit();
//        } catch (\Exception $e) {
//            Db::rollback();
//        }
//        $isPushed=QueuePub::later(2,QueueTypes::getQueueClass(QueueTypes::CLOSE_ORDER),['id'	=> '456f4ds56f4sd64f56sd'],QueueTypes::getQueue(QueueTypes::CLOSE_ORDER));
//        if( $isPushed !== false ){
//            echo date('Y-m-d H:i:s') . " a new Hello Job is Pushed to the MQ"."<br>";
//        }else{
//            echo 'Oops, something went wrong.';
//        }
    }

}
